package com.plian.system.service.yth.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.plian.Tools.CollectionUtil;
import com.plian.Tools.DateUtil;
import com.plian.Tools.EncryptUtil;
import com.plian.Tools.StringUtil;
import com.plian.system.constant.sys.FormTypeConstant;
import com.plian.system.entity.hr.staff.*;
import com.plian.system.entity.yth.stafffiles.*;
import com.plian.system.mapper.yth.staffFiles.*;
import com.plian.system.service.yth.IStafffilesService;
import com.plian.system.vo.hr.staff.*;
import com.plian.system.wrapper.hr.staff.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;

import static com.plian.system.constant.sys.BaseConstant.BASE64_KEY;

/**
 * 人员信息
 */
@Slf4j
@Service
//@DS("slave_1")
public class StaffServiceImpl extends ServiceImpl<PersonMapper, Person> implements IStafffilesService {

    private final String YTH_DATASOURCE_TYPE = "3";

    @Autowired
    private PersonAppoRemovalMapper appoRemovalMapper;
    @Autowired
    private PersonCertificateMapper certificateMapper;
    @Autowired
    private PersonEducationMapper educationMapper;
    @Autowired
    private PersonFamilyMapper familyMapper;
    @Autowired
    private PersonOverseasMemberMapper overseasMemberMapper;
    @Autowired
    private PersonRewardMapper rewardMapper;
    @Autowired
    private PersonStaffPostMapper staffPostMapper;
    @Autowired
    private PersonTechnologyMapper technologyMapper;
    @Autowired
    private PersonTrainMapper trainMapper;
    @Autowired
    private PersonYearAssessmentMapper yearAssessmentMapper;
    @Autowired
    private StaffFilesWrapper staffFilesWrapper;
    @Autowired
    private AppointRemoveWrapper appointRemoveWrapper;
    @Autowired
    private EducationDegreeWrapper educationDegreeWrapper;
    @Autowired
    private RewardsPunishmentsWrapper rewardsPunishmentsWrapper;
    @Autowired
    private AnnualAssessmentWrapper annualAssessmentWrapper;
    @Autowired
    private SocialRelationsWrapper socialRelationsWrapper;
    @Autowired
    private PractitionerCertificateWrapper practitionerCertificateWrapper;
    @Autowired
    private TechnicalQualificationWrapper technicalQualificationWrapper;
    @Autowired
    private TrainWrapper trainWrapper;
    @Autowired
    private OverseasMembersWrapper overseasMembersWrapper;
    @Autowired
    private WorkExperienceWrapper workExperienceWrapper;


    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
//    @DS("slave_1")
    @Override
    public List<StaffFilesVO> getSyncData(Date startTime, Date endTime) {
        List<StaffFilesVO> staffFilesVOList = new ArrayList<>();
        List<Person> personList = list(new LambdaQueryWrapper<Person>().isNotNull(Person::getId)
                .isNotNull(Person::getCreateTime)
                .gt(Optional.ofNullable(startTime).isPresent(), Person::getCreateTime, startTime)
                .le(Optional.ofNullable(endTime).isPresent(), Person::getCreateTime, endTime)
        );
        if (CollectionUtil.isNotEmpty(personList)) {
            staffFilesVOList = conversion(personList);
        }
        return staffFilesVOList;
    }


    /**
     * entity 转换
     *
     * @return
     * @param:
     * @date: 2023/4/18 4:22 PM
     * @author: jatpeo
     */
//    @DS("slave_1")
    private List<StaffFilesVO> conversion(List<Person> personList) {
        List<Long> ids = personList.stream().map(Person::getId).collect(Collectors.toList());
        //入职信息
        List<PersonStaffPost> personStaffPosts = staffPostMapper.selectList(new LambdaQueryWrapper<PersonStaffPost>().in(PersonStaffPost::getPersonId, ids));
        //教育情况
        List<PersonEducation> personEducations = educationMapper.selectList(new LambdaQueryWrapper<PersonEducation>().in(PersonEducation::getPersonId, ids));
        //任免记录
        List<PersonAppoRemoval> personAppoRemovals = appoRemovalMapper.selectList(new LambdaQueryWrapper<PersonAppoRemoval>().in(PersonAppoRemoval::getPersonId, ids));
        //奖罚
        List<PersonReward> personRewards = rewardMapper.selectList(new LambdaQueryWrapper<PersonReward>().in(PersonReward::getPersonId, ids));
        //考核结果
        List<PersonYearAssessment> personYearAssessments = yearAssessmentMapper.selectList(new LambdaQueryWrapper<PersonYearAssessment>().in(PersonYearAssessment::getPersonId, ids));
        //家庭
        List<PersonFamily> personFamilies = familyMapper.selectList(new LambdaQueryWrapper<PersonFamily>().in(PersonFamily::getPersonId, ids));
        //从业资格证书
        List<PersonCertificate> personCertificates = certificateMapper.selectList(new LambdaQueryWrapper<PersonCertificate>().in(PersonCertificate::getPersonId, ids));
        //专业技术资格
        List<PersonTechnology> personTechnologies = technologyMapper.selectList(new LambdaQueryWrapper<PersonTechnology>().in(PersonTechnology::getPersonId, ids));
        //近五年专业技术资格
        List<PersonTrain> personTrains = trainMapper.selectList(new LambdaQueryWrapper<PersonTrain>().in(PersonTrain::getPersonId, ids));
        //侨眷情况
        List<PersonOverseasMember> personOverseasMembers = overseasMemberMapper.selectList(new LambdaQueryWrapper<PersonOverseasMember>().in(PersonOverseasMember::getPersonId, ids));


        List<StaffFilesVO> staffFilesVOS = new ArrayList<>();

        for (Person person : personList) {
            StaffFiles staffFiles = new StaffFiles();
            staffFiles.setStaffName(person.getName());
            staffFiles.setDocumentTypeId(transDocumentTypeId(Objects.toString(person.getCertificatesType(), null)));
            staffFiles.setStaffCode(encryptDocumentNumber(person.getCertificatesNumber()));
            staffFiles.setDocumentNumber(encryptDocumentNumber(person.getCertificatesNumber()));
            staffFiles.setGenderId(transGenderId(Objects.toString(person.getSex(), null)));
            staffFiles.setBirthday(person.getBirthday() != null ? Date.from(person.getBirthday().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
            staffFiles.setNationId(transNationId(Objects.toString(person.getNation(), null)));
            staffFiles.setJoinPartyTime(person.getJoinDate() != null ? Date.from(person.getJoinDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
            staffFiles.setNativePlace(person.getNativePlace());
            staffFiles.setPlaceOfDomicile(person.getRegisteredResidence());
            staffFiles.setMaritalStatusId(transmaritalStatusId(Objects.toString(person.getMaritalStatus(), null)));
            staffFiles.setHealthConditionId(transHealthConditionId(Objects.toString(person.getHealthStatus(), null)));
            staffFiles.setCompanyNameId(Objects.toString(person.getCompanyId(), null));
            staffFiles.setEducationalId(transEducationalId(Objects.toString(person.getHighestEducation(), null)));
            staffFiles.setDegreeId(transDegreeId(Objects.toString(person.getHighestDegree(), null)));
            staffFiles.setTechnicalPosition(person.getTechnicalPosition());
            staffFiles.setPoliticCountenanceId(transPoliticCountenanceId(Objects.toString(person.getPolitical(), null)));
            staffFiles.setProfessionalQualification(person.getProfessionalQualification());
            staffFiles.setWorkTime(person.getWorkingDate() != null ? DateUtil.formatDate(Date.from(person.getWorkingDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())) : null);
            staffFiles.setTelephone(Objects.toString(person.getLinkPhone(), null));
            staffFiles.setEmail(person.getEmail());
            staffFiles.setWorkPhone(person.getWorkPhone());
            staffFiles.setFamilyAddress(person.getAddress());
            staffFiles.setBirthPlace(person.getBirthplace());
            staffFiles.setEmergencyContact(person.getEmergencyContactName());
            staffFiles.setEmergencyContactUs(person.getEmergencyContactPhone());
            staffFiles.setFormType(String.valueOf(FormTypeConstant.HR_STAFFFILES_FORM));
            staffFiles.setIsDeleted(0);
            staffFiles.setDataSource(YTH_DATASOURCE_TYPE);
            staffFiles.setDataSourceId(Objects.toString(person.getId(), null));
            /**
             * 入职信息在staffFiles单独工作经历
             *
             */
            List<WorkExperienceVO> workExperienceVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personStaffPosts)) {

                Optional<PersonStaffPost> personStaffPostOptional = personStaffPosts.stream().filter(e -> person.getId().equals(e.getPersonId())).findFirst();
                if (personStaffPostOptional.isPresent()) {
                    PersonStaffPost personStaffPost = personStaffPostOptional.get();
                    staffFiles.setCompanyInitiationTime(personStaffPost.getEntryDate() != null ? DateUtil.formatDate(Date.from(personStaffPost.getEntryDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())) : null);
                    staffFiles.setDepartmentNameId(Objects.toString(personStaffPost.getDeptName(), null));
                    staffFiles.setManagementCategoryId(Objects.toString(personStaffPost.getManageLevel(), null));
                    staffFiles.setJobCategoryId(transProposedPost(Objects.toString(personStaffPost.getPostId(), null)));
                    staffFiles.setJobNameId(personStaffPost.getPostName());
                    staffFiles.setRankId(transRankId(Objects.toString(personStaffPost.getPostLevel(), null)));
                    staffFiles.setCompilationTypeId(transCompilationTypeId(Objects.toString(personStaffPost.getEstablishmentCategory(), null)));
                    staffFiles.setResponsibilities(personStaffPost.getPostDuty());
                    staffFiles.setChangeEventsId(transChangeEventsId(Objects.toString(personStaffPost.getChangeEvent(), null)));
                    staffFiles.setChangeTypeId(transChangeTypeId(Objects.toString(personStaffPost.getChangeCategory(), null)));
                    staffFiles.setChangeReason(personStaffPost.getChangeReason());
                    staffFiles.setTalentCategory(personStaffPost.getTelantType());
                    staffFiles.setExpertise(personStaffPost.getExpertise());
                    staffFiles.setContractPeriod(personStaffPost.getContractPeriodDate() != null ? DateUtil.formatDate(Date.from(personStaffPost.getContractPeriodDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())) : null);
                    staffFiles.setChangeTime(personStaffPost.getChangeDate() != null ? Date.from(personStaffPost.getChangeDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    staffFiles.setIsReserveCadre(transJudgeStatus(personStaffPost.getReserveCadres()));
                    staffFiles.setIsCorporateTalent(transJudgeStatus(personStaffPost.getEnterpriseTalent()));
                    //存放部门名称字端
                    staffFiles.setDef1(personStaffPost.getDeptName());
                    /**
                     * 工作经历
                     */
                    String workExperience = personStaffPost.getWorkExperience();
                    staffFiles.setWorkExp(workExperience);
                    WorkExperience experience = new WorkExperience();
                    experience.setStaffFilesId(personStaffPost.getPersonId());
                    experience.setRemark(workExperience);
                    experience.setDataSource(YTH_DATASOURCE_TYPE);
                    experience.setDataSourceId(Objects.toString(personStaffPost.getId(), null));
                    WorkExperienceVO workExperienceVO = workExperienceWrapper.entityToVO(experience);
                    workExperienceVOS.add(workExperienceVO);
                }
            }

            StaffFilesVO staffFilesVO = new StaffFilesVO();
            BeanUtils.copyProperties(staffFiles, staffFilesVO);


            /**
             * 学历学位
             */
            List<EducationDegreeVO> educationDegreeVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personEducations)) {
                List<PersonEducation> educationList = personEducations.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonEducation personEducation : educationList) {
                    EducationDegree educationDegree = new EducationDegree();
                    educationDegree.setStartDate(personEducation.getBeginDate() != null ? Date.from(personEducation.getBeginDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    educationDegree.setEndDate(Date.from(personEducation.getEndDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
                    educationDegree.setEducationTypeId(transEducationTypeId(Objects.toString(personEducation.getEducationType(), null)));
                    educationDegree.setEducationalId(transEducationalId(Objects.toString(personEducation.getEducation(), null)));
                    educationDegree.setDegreeId(transDegreeId(Objects.toString(personEducation.getAcademicDegree(), null)));
                    educationDegree.setSchoolDepartmentMajor(personEducation.getGraduateColleges() + " " + personEducation.getMajor());
                    educationDegree.setIsHighestEducational(transJudgeStatus(personEducation.getHighestEducation()));
                    educationDegree.setIsHighestDegree(transJudgeStatus(personEducation.getHighestMajor()));
                    educationDegree.setIsDeleted(0);
                    educationDegree.setDataSource(YTH_DATASOURCE_TYPE);
                    educationDegree.setDataSourceId(Objects.toString(personEducation.getId(), null));
                    educationDegreeVOS.add(educationDegreeWrapper.entityToVO(educationDegree));
                }
            }
            // 任免记录
            List<AppointRemoveVO> appointRemoveVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personAppoRemovals)) {
                List<PersonAppoRemoval> appoRemovalList = personAppoRemovals.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonAppoRemoval item : appoRemovalList) {
                    AppointRemove appointRemove = new AppointRemove();
                    appointRemove.setAppointRemoveType(transAppointRemoveType(Objects.toString(item.getType(), null)));
                    appointRemove.setTakeOfficeCompany(item.getCompanyName());
                    appointRemove.setProposedPost(item.getAppointmentPostName());
                    appointRemove.setAppointRemovePost(item.getRemovalPostName());
                    appointRemove.setAppointRemoveReason(item.getReason());
                    appointRemove.setIsDeleted(0);
                    appointRemove.setCollocationMethod("");//no
                    appointRemove.setBusinessLeadersCategory(Objects.toString(item.getLeaderCategory(), null));
                    appointRemove.setAppointRemoveSource(item.getSource());
                    appointRemove.setMeetingDecisionDate(item.getDecisionMeetDate() != null ? Date.from(item.getDecisionMeetDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    appointRemove.setDataSource(YTH_DATASOURCE_TYPE);
                    appointRemove.setDataSourceId(Objects.toString(item.getId(), null));
                    appointRemoveVOS.add(appointRemoveWrapper.entityToVO(appointRemove));
                }
            }
            //奖惩情况
            List<RewardsPunishmentsVO> rewardsPunishmentsVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personRewards)) {
                List<PersonReward> rewardList = personRewards.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonReward personReward : rewardList) {
                    RewardsPunishments rewardsPunishments = new RewardsPunishments();
                    rewardsPunishments.setRewardPunishmentMarks(Objects.toString(personReward.getRewardPunishmentSign(), null));
                    rewardsPunishments.setHonorAwardName(personReward.getRewardName());
                    rewardsPunishments.setRewardPunishmentLevel(personReward.getRewardLevel());
                    rewardsPunishments.setRewardDate(personReward.getRewardDate() != null ? Date.from(personReward.getRewardDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    rewardsPunishments.setGrantingUnitName(personReward.getAwardedCompany());
                    rewardsPunishments.setPrizeCertificateNumber(personReward.getNumber());
                    rewardsPunishments.setIsDeleted(0);
                    rewardsPunishments.setDataSource(YTH_DATASOURCE_TYPE);
                    rewardsPunishments.setDataSourceId(Objects.toString(personReward.getId(), null));
                    rewardsPunishmentsVOS.add(rewardsPunishmentsWrapper.entityToVO(rewardsPunishments));
                }
            }
            //年度考核结果
            List<AnnualAssessmentVO> annualAssessmentVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personYearAssessments)) {
                List<PersonYearAssessment> yearAssessmentList = personYearAssessments.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonYearAssessment personYearAssessment : yearAssessmentList) {
                    AnnualAssessment annualAssessment = new AnnualAssessment();
                    annualAssessment.setAssessmentYear(personYearAssessment.getAssessmentYear());
                    annualAssessment.setAssessmentResult(Objects.toString(personYearAssessment.getAssessmentResult(), null));//dict
                    annualAssessment.setDataSource(YTH_DATASOURCE_TYPE);
                    annualAssessment.setIsDeleted(0);
                    annualAssessment.setDataSourceId(Objects.toString(personYearAssessment.getId(), null));
                    annualAssessmentVOS.add(annualAssessmentWrapper.entityToVO(annualAssessment));
                }
            }
            //家庭及社会关系
            List<SocialRelationsVO> socialRelationsVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personFamilies)) {
                List<PersonFamily> familieList = personFamilies.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonFamily personFamily : familieList) {
                    SocialRelations socialRelations = new SocialRelations();
                    socialRelations.setAppellation(personFamily.getAppellation());
                    socialRelations.setFullName(personFamily.getName());
                    socialRelations.setBirthday(personFamily.getBirthday() != null ? Date.from(personFamily.getBirthday().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    socialRelations.setPoliticCountenanceId(transPoliticCountenanceId(Objects.toString(personFamily.getPolitical(), null)));
                    socialRelations.setWorkUnit(personFamily.getCompany());
                    socialRelations.setJobNameId(personFamily.getPost());
                    socialRelations.setDataSource(YTH_DATASOURCE_TYPE);
                    socialRelations.setIsDeleted(0);
                    socialRelations.setDataSourceId(Objects.toString(personFamily.getId(), null));
                    socialRelationsVOS.add(socialRelationsWrapper.entityToVO(socialRelations));
                }
            }
            //从业资格证书
            List<PractitionerCertificateVO> practitionerCertificateVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personCertificates)) {
                List<PersonCertificate> certificateList = personCertificates.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonCertificate personCertificate : certificateList) {
                    PractitionerCertificate practitionerCertificate = new PractitionerCertificate();
                    practitionerCertificate.setPractitionerCertificateName(personCertificate.getCertificateName());
                    practitionerCertificate.setPractitionerCertificateLevel(transPractitionerCertificateLevel(Objects.toString(personCertificate.getLevel(), null)));
                    practitionerCertificate.setBuildDate(personCertificate.getAcquisitionDate() != null ? Date.from(personCertificate.getAcquisitionDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    practitionerCertificate.setEffectiveTime(personCertificate.getEffectiveTime() != null ? DateUtil.parse(personCertificate.getEffectiveTime(), DateUtil.PATTERN_DATETIME) : null);
                    practitionerCertificate.setIsDeleted(0);
                    practitionerCertificate.setDataSource(YTH_DATASOURCE_TYPE);
                    practitionerCertificate.setDataSourceId(Objects.toString(practitionerCertificate.getId(), null));
                    practitionerCertificateVOS.add(practitionerCertificateWrapper.entityToVO(practitionerCertificate));
                }
            }
            //专业技术资格
            List<TechnicalQualificationVO> technicalQualificationVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personTechnologies)) {
                List<PersonTechnology> technologieList = personTechnologies.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonTechnology personTechnology : technologieList) {
                    TechnicalQualification technicalQualification = new TechnicalQualification();
                    technicalQualification.setTechnicalTitleType(personTechnology.getType());
                    technicalQualification.setTechnicalTitleLevelId(transtTechnicalTitleLevelId(Objects.toString(personTechnology.getLevel(), null)));
                    technicalQualification.setTechnicalTitleName(personTechnology.getName());
                    technicalQualification.setBuildDate(personTechnology.getAcquisitionDate() != null ? Date.from(personTechnology.getAcquisitionDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    technicalQualification.setIsDeleted(0);
                    technicalQualification.setDataSource(YTH_DATASOURCE_TYPE);
                    technicalQualification.setDataSourceId(Objects.toString(personTechnology.getId(), null));
                    technicalQualificationVOS.add(technicalQualificationWrapper.entityToVO(technicalQualification));
                }

            }
            //近五年三月以上培训情况
            List<TrainVO> trainVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personTrains)) {
                List<PersonTrain> trainList = personTrains.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonTrain personTrain : trainList) {
                    Train train = new Train();
                    train.setStartTime(personTrain.getBeginDate() != null ? Date.from(personTrain.getBeginDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    train.setEndTime(personTrain.getEndDate() != null ? Date.from(personTrain.getEndDate().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
                    train.setClasses(personTrain.getClassNumber());
                    train.setIsDeleted(0);
                    train.setDataSource(YTH_DATASOURCE_TYPE);
                    train.setDataSourceId(Objects.toString(personTrain.getId(), null));
                    trainVOS.add(trainWrapper.entityToVO(train));
                }
            }
            //侨眷情况
            List<OverseasMembersVO> overseasMembersVOS = new ArrayList<>();
            if (CollectionUtil.isNotEmpty(personOverseasMembers)) {
                List<PersonOverseasMember> overseasMemberList = personOverseasMembers.stream().filter(item -> item.getPersonId().equals(person.getId())).collect(Collectors.toList());
                for (PersonOverseasMember personOverseasMember : overseasMemberList) {
                    OverseasMembers overseasMembers = new OverseasMembers();
                    overseasMembers.setOverseasName(personOverseasMember.getName());
                    overseasMembers.setOverseasSex(transGenderId(Objects.toString(personOverseasMember.getSex(), null)));
                    overseasMembers.setHostCountry(personOverseasMember.getCountryCity());
                    overseasMembers.setOccupation(personOverseasMember.getOccupation());
                    overseasMembers.setRelationship(personOverseasMember.getRalation());
                    overseasMembers.setIsDeleted(0);
                    overseasMembers.setDataSource(YTH_DATASOURCE_TYPE);
                    overseasMembers.setDataSourceId(Objects.toString(personOverseasMember.getId(), null));
                    overseasMembersVOS.add(overseasMembersWrapper.entityToVO(overseasMembers));
                }
            }
            staffFilesVO.setAppointRemoveVO(appointRemoveVOS);
            staffFilesVO.setWorkExperienceVO(workExperienceVOS);
            staffFilesVO.setRewardsPunishmentsVO(rewardsPunishmentsVOS);
            staffFilesVO.setAnnualAssessmentVO(annualAssessmentVOS);
            staffFilesVO.setSocialRelationsVO(socialRelationsVOS);
            staffFilesVO.setPractitionerCertificateVO(practitionerCertificateVOS);
            staffFilesVO.setTechnicalQualificationVO(technicalQualificationVOS);
            staffFilesVO.setTrainVO(trainVOS);
            staffFilesVO.setOverseasMembersVO(overseasMembersVOS);
            staffFilesVOS.add(staffFilesVO);
        }

        return staffFilesVOS;
    }

    /**
     * 加密证件号
     *
     * @param certificatesNumber
     * @return
     */
    private String encryptDocumentNumber(String certificatesNumber) {
        if (StringUtil.isNotBlank(certificatesNumber)) {
            return EncryptUtil.encryptBase64(certificatesNumber, BASE64_KEY);
        }
        return null;
    }

    /**
     * 级别
     *
     * @param value
     * @return
     */
    private String transPractitionerCertificateLevel(String value) {
        if (Optional.ofNullable(value).isPresent()) {
            switch (value) {
                case "1":
                    return "高级";
                case "2":
                    return "中级";
                case "3":
                    return "初级";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 专业技术级别
     *
     * @param value
     * @return
     */
    private String transtTechnicalTitleLevelId(String value) {
        if (Optional.ofNullable(value).isPresent()) {
            switch (value) {
                case "1":
                    return "038001";
                case "2":
                    return "038002";
                case "3":
                    return "038003";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 异动类型
     *
     * @param value
     * @return
     */
    private String transChangeTypeId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            int code = valueCode + 1;
            if (valueCode < 10) {
                return "03600" + code;
            } else {
                return "0360" + code;
            }
        }
        return null;
    }

    /**
     * 异动事件
     *
     * @param value
     * @return
     */
    private String transChangeEventsId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            int code = valueCode + 1;
            if (valueCode < 10) {
                return "03500" + code;
            } else {
                return "0350" + code;
            }
        }
        return null;
    }

    /**
     * 编制类型
     *
     * @param value
     * @return
     */
    private String transCompilationTypeId(String value) {
        if (Optional.ofNullable(value).isPresent()) {
            switch (value) {
                case "1":
                    return "028001";
                case "0":
                    return "028002";
                case "3":
                    return "028003";
                case "10":
                    return "028004";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 职级
     *
     * @param value
     * @return
     */
    private String transRankId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            int code = valueCode + 1;
            if (valueCode < 10) {
                return "03300" + code;
            } else {
                return "0330" + code;
            }
        }
        return null;
    }

    /**
     * 政治面貌
     *
     * @param value
     * @return
     */
    private String transPoliticCountenanceId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            int code = valueCode + 1;
            if (valueCode < 10) {
                return "02200" + code;
            } else if (valueCode >= 10 && valueCode < 13) {
                return "0220" + code;
            }
            return null;
        }
        return null;
    }

    /**
     * 职务类型
     *
     * @param value
     * @return
     */
    private String transProposedPost(String value) {
        if (Optional.ofNullable(value).isPresent()) {
            switch (value) {
                case "1":
                    return "职能管理类";
                case "2":
                    return "技术类";
                case "3":
                    return "生产类";
                case "4":
                    return "服务后勤类";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 任免类型
     *
     * @param value
     * @return
     */
    private String transAppointRemoveType(String value) {
        if (Optional.ofNullable(value).isPresent()) {
            switch (value) {
                case "0":
                    return "选任制";
                case "1":
                    return "委任制";
                case "2":
                    return "聘任制";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 判断是否
     *
     * @param value
     * @return
     */
    private Integer transJudgeStatus(Integer value) {
        if (Optional.ofNullable(value).isPresent()) {
            switch (value) {
                case 1:
                    return 2;
                case 0:
                    return 1;
                default:
                    return 2;
            }
        }
        return 2;
    }

    /**
     * 教育类型
     *
     * @param value
     * @return
     */
    private String transEducationTypeId(String value) {
        if (StringUtil.isNotBlank(value)) {
            switch (value) {
                case "1":
                    return "037001";
                case "2":
                    return "037002";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 学历
     *
     * @param value
     * @return
     */
    private String transDegreeId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            return "02600" + valueCode;
        }
        return null;
    }

    /**
     * 教育信息
     *
     * @param
     * @return
     */
    private String transEducationalId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            int code = valueCode + 1;
            if (valueCode < 10) {
                return "02500" + code;
            } else {
                return "0250" + code;
            }
        }
        return null;
    }

    /**
     * 证件类型
     *
     * @return
     */
    private String transDocumentTypeId(String value) {
        if (StringUtil.isNotBlank(value)) {
            switch (value) {
                case "0":
                    return "019001";
                case "8":
                    return "019002";
                case "7":
                    return "019003";
                case "10":
                    return "019004";
                case "23":
                    return "019005";
                case "26":
                    return "019006";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 性别
     *
     * @return
     */
    private String transGenderId(String value) {
        if (StringUtil.isNotBlank(value)) {
            switch (value) {
                case "1":
                    return "020001";
                case "2":
                    return "020002";
                default:
                    return null;
            }
        }
        return null;
    }

    /**
     * 民族类型
     *
     * @return
     */
    private String transNationId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            int code = valueCode + 1;
            if (valueCode < 10) {
                return "02100" + code;
            } else {
                return "0210" + code;
            }
        }
        return null;
    }

    /**
     * 婚姻
     *
     * @return
     */
    private String transmaritalStatusId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            return "02400" + valueCode;
        }
        return null;
    }

    /**
     * 健康状态
     *
     * @return
     */
    private String transHealthConditionId(String value) {
        if (StringUtil.isNotBlank(value)) {
            Integer valueCode = Integer.valueOf(value);
            return "11200" + valueCode;
        }
        return null;
    }


}
